﻿using System.Linq;
using LINQtoFxCop.Core;
using AssemblyNode=LINQtoFxCop.Core.AssemblyNode;


namespace LINQtoFxCop.Metrics
{
  public static class AssemblyMetrics
  {
    public static int NbILInstructions(this AssemblyNode assembly)
    {
      return assembly.Types.Sum(type => type.NbILInstructions());
    }
    public static int NbMethods(this AssemblyNode assembly)
    {
      return assembly.Types.Sum(type => type.NbMethods());
    }
    public static int NbNamespaces(this AssemblyNode assembly)
    {
      var namespaces = new NamespaceCollection {assembly.Types};
      return namespaces.Count;
    }
    public static int NbFields(this AssemblyNode assembly)
    {
      return assembly.Types.Sum(type => type.NbFields());
    }

    public static int NbTypes(this AssemblyNode assembly)
    {
      return assembly.Types.Count();
    }
  }
}
